package com.wwdablu.soumya.lottiebottomnav;

import ohos.agp.text.Font;
import ohos.agp.utils.Color;

/**
 * FontBuilder
 *
 * @since 2021-05-19
 */
public final class FontBuilder {
    private FontItem fontItem;

    private FontBuilder(FontItem fontItem) {
        this.fontItem = new FontItem(fontItem);
    }

    private FontBuilder(String spannableTitle) {
        fontItem = new FontItem(spannableTitle, Color.BLACK.getValue(), Color.GRAY.getValue(), 10, 10, null);
    }

    /**
     * create
     *
     * @param title
     * @return FontBuilder
     * @throws IllegalArgumentException
     */
    public static FontBuilder create(String title) {
        if (title.trim().length() == 0) {
            throw new IllegalArgumentException("Title cannot be empty");
        }

        return new FontBuilder(title);
    }

    /**
     * create
     *
     * @param fontItem
     * @return FontBuilder
     */
    public static FontBuilder create(FontItem fontItem) {
        return new FontBuilder(fontItem);
    }

    /**
     * selectedTextColor
     *
     * @param color
     * @return FontBuilder
     */
    public FontBuilder selectedTextColor(int color) {
        fontItem.setTextSelectedColor(color);
        return this;
    }

    /**
     * unSelectedTextColor
     *
     * @param color
     * @return FontBuilder
     */
    public FontBuilder unSelectedTextColor(int color) {
        fontItem.setTextUnselectedColor(color);
        return this;
    }

    /**
     * setTypeface
     *
     * @param typeface
     * @return FontBuilder
     */
    public FontBuilder setTypeface(Font typeface) {
        fontItem.setTypefaceCompat(typeface);
        return this;
    }

    /**
     * setTitle
     *
     * @param title
     * @return FontBuilder
     */
    public FontBuilder setTitle(String title) {
        fontItem.setTitle(title);
        return this;
    }

    /**
     * Provide the value in SP. For example for 10SP, just provide 10
     *
     * @param textSize Text size in SP
     * @return FontBuilder
     */
    public FontBuilder selectedTextSize(int textSize) {
        fontItem.setSelectedTextSize(textSize);
        return this;
    }

    /**
     * Provide the value in SP. For example for 10SP, just provide 10
     *
     * @param textSize Text size in SP
     * @return FontBuilder
     */
    public FontBuilder unSelectedTextSize(int textSize) {
        fontItem.setUnselectedTextSize(textSize);
        return this;
    }

    /**
     * build
     *
     * @return FontItem
     */
    public FontItem build() {
        return fontItem;
    }
}
